<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class SignUp extends CI_Controller {
	function __construct()
	{
		parent::__construct();
	}

	function index()
	{
		$this->load->library('form_validation');
		$this -> load -> model('login_model','',TRUE);

		$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
		$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|callback_check_database');

		if($this->form_validation->run() == FALSE)
		{
			//Field validation failed. User redirected to login page
			$this -> load -> helper(array('form'));
			$data['contents'] = $this -> load -> view('sign_up_view','',true);
			$data['page_title'] = 'Sign Up';
			$this -> load -> view('template_default',$data);
		}
		else
		{
			//Go to private area
			$this -> login_model -> sign_up();
			$data['url'] = base_url();
			$data['message'] = 'Success...';
			$this -> load -> view('loading_view', $data);
		}
	}
}
?>
